#include "ACut.h" 
void ACut::Set_Pt_Cut(CPT   pt_cut  , int i){
	SWITCH = pt_cut.JCUT_pt[i];
	obj    = 0.0;
	d  = pt_cut.CUT_ptd[i];
	u  = pt_cut.CUT_ptu[i];
}
void ACut::Set_Eta_Cut(CETA  eta_cut , int i){
	SWITCH = eta_cut.JCUT_eta[i];
	obj    = 0.0;
	d  = eta_cut.CUT_etad[i];
	u  = eta_cut.CUT_etau[i];
}
void ACut::Set_Mass_Cut(CMASS mass_cut, int i){
	SWITCH = mass_cut.JCUT_mass[i];
	obj    = mass_cut.CUT_massr[i];
	d  = mass_cut.CUT_massd[i];
	u  = mass_cut.CUT_massu[i];
}
void ACut::Set_Mt_Cut(CMT   mt_cut  , int i){
	SWITCH = mt_cut.JCUT_mt[i];
	obj    = 0.0;
	d  = mt_cut.CUT_mtd[i];
	u  = mt_cut.CUT_mtu[i];
}

void ACut::Print(int level, std::string cut_name){
	printf("\n"); // ]label the columns
	printf("The cut is for %12s, open: %12i obj: %12.5f up_limit: %12.5f down_limit: %12.5f \n", cut_name.c_str(), SWITCH, obj, d, u); 
}

std::ostream & operator<<(std::ostream & ostr, ACut& cut){
	printf("\n"); // ]label the columns
	printf("The cut is open: %12i obj: %12.5f up_limit: %12.5f down_limit: %12.5f \n", cut.SWITCH, cut.obj, cut.d, cut.u); 
	return ostr;
}


void ACuts::Print(int level, std::string cut_name){
	ShowMessage(level,"the cuts name is", cut_name);
	m  .Print(level+1, "mass");
	mt .Print(level+1, "mt");
	pt .Print(level+1, "pt");
	eta.Print(level+1, "eta");
}

void CCombine_cut::Print(){
	printf("\n   total cut num is ", CUT_num);
	for(int i=0;i<CUT_num;i++){
		printf("\n      cut is open: %12i \n",JCUT[i]);
		printf("\n      Mass: %12i %12.5f %12.5f %12.5f %12.5f \n",JCUT_mass[i], CUT_massr[i], CUT_massbin[i], CUT_massd[i], CUT_massu[i]);
		printf("      MT: %12i %12.5f %12.5f \n",JCUT_mt[i], CUT_mtd[i], CUT_mtu[i]);
		printf("      PT: %12i %12.5f %12.5f \n",JCUT_pt[i], CUT_ptd[i], CUT_ptu[i]);
		printf("      ETA: %12i %12.5f %12.5f \n",JCUT_eta[i], CUT_etad[i], CUT_etau[i]);

	}

}

void ACuts_Vector::Set_Mass_Cut(CMASS &mass_cut){
	ShowMessage(3,"Set ACuts Vector: Set_Mass_Cut", mass_cut.CUT_massd.size());
	for(int i=0; i<mass_cut.CUT_massd.size(); i++){
		cut_vector[i].m.Set_Mass_Cut(mass_cut, i);
	}
}

void ACuts_Vector::Set_Mt_Cut(CMT &mt_cut){
	ShowMessage(3,"Set ACuts Vector: Set_Mt_Cut", mt_cut.CUT_mtd.size());
	for(int i=0; i<mt_cut.CUT_mtd.size(); i++){
		cut_vector[i].mt.Set_Mt_Cut(mt_cut, i);
	}
}

void ACuts_Vector::Set_Pt_Cut(CPT &pt_cut){
	ShowMessage(3,"Set ACuts Vector: Set_PT_Cut", pt_cut.CUT_ptd.size());
	for(int i=0; i<pt_cut.CUT_ptd.size(); i++){
		cut_vector[i].pt.Set_Pt_Cut(pt_cut, i);
	}
}

void ACuts_Vector::Set_Eta_Cut(CETA &eta_cut){
	ShowMessage(3,"Set ACuts Vector: Set_Eta_Cut", eta_cut.CUT_etad.size());
	for(int i=0; i<eta_cut.CUT_etad.size(); i++){
		cut_vector[i].eta.Set_Eta_Cut(eta_cut, i);
	}
}

void ACuts_Vector::Set_Cuts(CCombine_cut &comb_cut){
	ShowMessage(3,"Set ACuts Vector");
	cut_vector.resize(comb_cut.CUT_massd.size());
	Set_Mass_Cut(comb_cut);
	Set_Mt_Cut(comb_cut);
	Set_Pt_Cut(comb_cut);
	Set_Eta_Cut(comb_cut);
}

void ACuts_Vector::Print(int level, std::string str){
	ShowMessage(level,"In ACuts_vector, for", str);
	ShowMessage(level+1,"In this cut vector, total element number", cut_vector.size());
	for(int i=0; i<cut_vector.size(); i++){
		cut_vector[i].m.Print  (level+1, "mass");
		cut_vector[i].mt.Print (level+1, "mt");
		cut_vector[i].pt.Print (level+1, "pt");
		cut_vector[i].eta.Print(level+1, "eta");
	}
}

/*
std::ostream & operator<<(std::ostream & ostr, ACuts_Vector & cuts){
	printf("\n In this cut vector, totally %12i element", cuts.cut_vector.size());
	for(int i=0; i<cuts.cut_vector.size(); i++){
		std::cout << cuts.cut_vector[i] << std::endl;
	}
	return ostr;
}*/
